import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';
import '../repositories/auth_repository.dart';
import '../repositories/auth_repository_factory.dart';
import '../repositories/app_state_repository.dart';
import '../repositories/mood_repository.dart';
import '../repositories/mood_repository_factory.dart';
import '../repositories/timeline_repository.dart';
import '../repositories/important_days_repository.dart';
import '../repositories/impl/mock_app_state_repository.dart';
import '../repositories/impl/mock_timeline_repository.dart';
import '../repositories/impl/mock_important_days_repository.dart';
import '../providers/auth_provider.dart';
import '../providers/app_state_provider.dart';
import '../providers/mood_provider.dart';
import '../providers/timeline_provider.dart';
import '../providers/important_days_provider.dart';

class DependencyInjection {
  static List<SingleChildWidget> get providers => [
    // Repository 层
    Provider<AuthRepository>(
      create: (context) => AuthRepositoryFactory.create(),
    ),
    Provider<AppStateRepository>(
      create: (context) => MockAppStateRepository(),
    ),
    Provider<MoodRepository>(
      create: (context) => MoodRepositoryFactory.create(),
    ),
    Provider<TimelineRepository>(
      create: (context) => MockTimelineRepository(),
    ),
    Provider<ImportantDaysRepository>(
      create: (context) => MockImportantDaysRepository(),
    ),
    
    // Provider 层 - AuthProvider 必须是第一个
    ChangeNotifierProvider<AuthProvider>(
      create: (context) => AuthProvider(
        repository: AuthRepositoryFactory.create(),
      ),
    ),
    ChangeNotifierProvider<AppStateProvider>(
      create: (context) => AppStateProvider(
        context.read<AppStateRepository>(),
      ),
    ),
    ChangeNotifierProvider<MoodProvider>(
      create: (context) => MoodProvider(
        context.read<MoodRepository>(),
      ),
    ),
    ChangeNotifierProvider<TimelineProvider>(
      create: (context) => TimelineProvider(
        context.read<TimelineRepository>(),
      ),
    ),
    ChangeNotifierProvider<ImportantDaysProvider>(
      create: (context) => ImportantDaysProvider(
        context.read<ImportantDaysRepository>(),
      ),
    ),
  ];
}